Skip to main content

All Questions

Tagged with
3votes
0answers
98views

Comparing two Tree sort algorithm variations implemented in Java

I have this repository. It contains three variations of a simple sorting algorithm for integer keys. The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
coderodde's user avatar
2votes
1answer
85views

Implementing an improved merge sort that uses insertion sort, with "levels" - Would this work correctly?

We were asked to improve the merge sort algorithm by introducing insertion sort to the code. We have been tasked with doing this by utilising a "levels" logic. Here is the exact description ...
Preatorius's user avatar
3votes
2answers
216views

Counting duplicate elements in two sorted arrays

I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
Bryan C's user avatar
2votes
2answers
193views

Quick Sort Program

Quick sort is a sorting algorithm in which we select any random element as pivot from the array and we do the partition of the array around that pivot. Basically we place all the elements smaller than ...
Strange Alchemist's user avatar
1vote
1answer
255views

Find Kth Element in the merged two sorted arrays?

We have been given two sorted arrays and a number K . We have to merge the two sorted arrays in the sorted manner and return the element at the Kth position. My approach is to use two variables ...
Aryaman 's user avatar
5votes
1answer
348views

ZigZag array implementation

I have implemented a zigzag array which will sort smaller greater smaller and goes on... For example : 3 7 4 8 2 6 1 is a valid ordering. The relationship between numbers is 3 < 7 > 4 < 8 >...
Neslihan Bozer's user avatar
2votes
1answer
224views

Efficient counting sort for large byte arrays in Java

I have this counting sort for byte values running in linear time with respect to array length: Arrays.java ...
coderodde's user avatar
0votes
2answers
144views

ContactsList implementation in Java

I created a ContactsList class in Java that holds Person objects. I consider this is a side project for my GitHub profile. Any ...
Hamidur Rahman's user avatar
3votes
2answers
384views

Check whether array is sorted recursively

I'm trying to implement isSorted method checking whether given array is sorted recursively. I've written two types, one is similar to merge sort logic, the another ...
Soner from The Ottoman Empire's user avatar
1vote
2answers
95views

Mergesort, instrumented for counting reads and writes

I have just finished an implementation of mergesort, and I was wondering if I can further reduce the amount of reads and writes. I have looked at it for a while, and to my eyes, I cannot see anything ...
joeyvanlierop's user avatar
0votes
1answer
1kviews

Sort multidimensional array based of the difference in the value

Sort multidimensional array based of the difference in the value, if value is same sort on first column. Constrains: No of rows can be any but fixed no of column ie 2. Example: <...
Sandesh Wani's user avatar
4votes
1answer
1kviews

Repeated comparison of sorted subarrays

This question is from a recently concluded competition on Codechef. You are given an array A of size n, and there are ...
Ravi Chandra's user avatar
3votes
2answers
297views

Segregate an array of 0s and 1s

I think that my code contains a lot of if and else statements that are probably not required.I suppose that this code could be condensed to a shorter form where the logic applied would look clearer ...
Mayank Gupta's user avatar
3votes
3answers
9kviews

Sorting integers in descending order

So, I coded a program which asks you the number of integers and the integers the user wants to sort in descending order. The program works but I feel like it is very inefficient. If I were to receive ...
Huzo's user avatar
  • 287
4votes
1answer
2kviews

Find distinct combinations of four elements in an array that have a certain sum

The task is: Given an array A of size N, find all combinations of four elements in the array whose sum is equal to a given value K. The specific requirements are: The combinations must be distinct ...
umop apisdn's user avatar

153050per page
close